In [1]:
%matplotlib inline
import seaborn as sns
sns.set_style('whitegrid')
sns.set_context('notebook')
import warnings from IPython.utils.shimmodule import ShimWarning warnings.filterwarnings('error','', ShimWarning)
In [2]:
from iuvs import io
In [3]:
from iuvs.apoapse import *
The selector is a dataframe of booleans that check for each integration which spatial pixels are on the Martian disk, meaning their 'over-limb altitude' is larger 0:
In [4]:
sns.set_context('talk')
In [5]:
from ipyparallel import Client
In [17]:
c = Client()
In [18]:
lbview = c.load_balanced_view()
In [19]:
def process_daystring(daystring):
from iuvs.apoapse import process_day
process_day(daystring, 255)
In [20]:
days = [str(i) for i in range(20141110,20141120)]
In [12]:
results = lbview.map_async(process_daystring, days)
In [13]:
for res in results:
print(res)
In [150]:
process_days(['20150109'], 290, channel='muv')
In [7]:
%matplotlib nbagg
In [8]:
sns.set_context('talk')
In [9]:
def shift_lons(lon):
if lon > 180:
return -(360 - lon)
else:
return lon
In [25]:
df1 = pd.read_hdf('/home/klay6683/to_keep/apoapse/muv_20141117_290.h5')
df2 = pd.read_hdf('/home/klay6683/to_keep/apoapse/muv_20150209_290.h5')
fig, axes = plt.subplots(nrows=2, sharex=False, figsize=(8,6))
vmax = max(df1.data.max(), df2.data.max())
for ax, df,t in zip(axes, [df1, df2], ['20141117, Ls 235', '20150209, Ls 288']): #, df2, df3]):
df.lons = df.lons.map(shift_lons)
df.plot(kind='hexbin', x='lons', y='lats', C='data', mincnt=1, gridsize=35,
cmap='viridis', title='L1B, 290 nm, '+t, vmax=vmax, ax=ax,
ylim=(-90,0))
fig.tight_layout()
fig.savefig('L1B_comparison_lons_swapped.pdf', dpi=150)
In [35]:
df1 = pd.read_hdf('/home/klay6683/to_keep/apoapse/muv_20141117_255.h5')
df2 = pd.read_hdf('/home/klay6683/to_keep/apoapse/muv_20141117_290.h5')
fig, axes = plt.subplots(nrows=2, sharex=False)
vmax = max(df1.data.max(), df2.data.max())
for ax, df,t in zip(axes, [df1, df2], ['255 nm', '290 nm']): #, df2, df3]):
df.plot(kind='hexbin', x='lons', y='lats', C='data', mincnt=1, gridsize=35,
cmap='viridis', title='20141117, L_s=233, '+t, vmax=vmax, ax=ax)
fig.tight_layout()
In [155]:
plt.figure()
df = df255
plt.hexbin(df.lons, df.lats, df.data, mincnt=1, gridsize=35,
cmap='viridis', vmax=df300.data.max())
plt.colorbar()
Out[155]:
In [156]:
plt.figure()
df = df300
plt.hexbin(df.lons, df.lats, df.data, mincnt=1, gridsize=35,
cmap='viridis', vmax=df.data.max())
plt.colorbar()
Out[156]:
In [38]:
df0 = pd.read_hdf('/home/klay6683/to_keep/apoapse/muv_20141117_290.h5')
df1 = pd.read_hdf('/home/klay6683/to_keep/apoapse/muv_20141215_290.h5')
df2 = pd.read_hdf('/home/klay6683/to_keep/apoapse/muv_20150115_290.h5')
df3 = pd.read_hdf('/home/klay6683/to_keep/apoapse/muv_20150209_290.h5')
fig, axes = plt.subplots(nrows=2, sharex=False)
vmax = df1.data.max()
for ax, df,t in zip(axes, [df0, df3], ['20141117, Ls 235', '20150209, Ls 288']): #, df2, df3]):
df.plot(kind='hexbin', x='lons', y='lats', C='data', mincnt=1, gridsize=35,
cmap='viridis', vmax=vmax, ax=ax, title=t)
fig.tight_layout()
In [192]:
df0 = pd.read_hdf('/home/klay6683/to_keep/apoapse/muv_20141117_300.h5')
df1 = pd.read_hdf('/home/klay6683/to_keep/apoapse/muv_20141215_300.h5')
df2 = pd.read_hdf('/home/klay6683/to_keep/apoapse/muv_20150115_300.h5')
df3 = pd.read_hdf('/home/klay6683/to_keep/apoapse/muv_20150209_300.h5')
fig, axes = plt.subplots(nrows=2, sharex=True)
vmax = df1.data.max()
for ax, df,t in zip(axes, [df0, df3], ['Ls 233','Ls 288']): #, df2, df3]):
df.plot(kind='hexbin', x='lons', y='lats', C='data', mincnt=1, gridsize=35,
cmap='viridis', vmax=vmax, ax=ax, title=t)
In [128]:
plt.hexbin?
In [106]:
df = pd.read_hdf('/home/klay6683/to_keep/apoapse/muv_20141117.h5')
plt.figure()
plt.hexbin(df.lons, df.lats, df.data, mincnt=1, gridsize=30,
cmap='viridis')
plt.colorbar()
Out[106]:
In [ ]:
lats, lons, data = process_fnames(io.l1b_filenames('apoapse*-muv_2015021*T',
env='production'))
fig, axes = plt.subplots(nrows=2, sharex=True)
gridsize = 35
mincnt = 1
extent = [0, 360, -90, 50]
im0 = axes[0].hexbin(lons, lats, C=data, gridsize=gridsize, mincnt=mincnt, cmap='viridis',
extent=extent)
plt.colorbar(im0, ax=axes[0])
axes[0].set_title('Dates: 2015021*T , Mean L1B.HDU[0] values')
im1 = axes[1].hexbin(lons, lats, gridsize=gridsize, mincnt=mincnt, cmap='viridis',
extent=extent)
axes[1].set_title('N entries in bin')
plt.colorbar(im1, ax=axes[1])
axes[1].set_xlabel('Longitude')
for ax in axes:
ax.set_ylabel('Latitude')
fig.tight_layout()
In [ ]:
# lats, lons, data = process_fnames(io.l1b_filenames('apoapse*-muv_2014111*T',
# env='production'))
fig, axes = plt.subplots(nrows=2, sharex=True)
gridsize = 35
mincnt = 1
extent = [0, 360, -90, 50]
im0 = axes[0].hexbin(lons, lats, C=data, gridsize=gridsize, mincnt=mincnt, cmap='viridis',
extent=extent)
plt.colorbar(im0, ax=axes[0])
axes[0].set_title('Dates: 2014111*T , Mean L1B.HDU[0] values')
im1 = axes[1].hexbin(lons, lats, gridsize=gridsize, mincnt=mincnt, cmap='viridis',
extent=extent)
axes[1].set_title('N entries in bin')
plt.colorbar(im1, ax=axes[1])
axes[1].set_xlabel('Longitude')
for ax in axes:
ax.set_ylabel('Latitude')
fig.tight_layout()
In [193]:
globstr = "apoapse*-{}_{}T".format('muv', '201111?')
In [156]:
fnames = io.l1b_filenames(globstr, env='production', iterator=False)
In [157]:
fnames.sort()
In [158]:
def process_fname(fname):
from iuvs.apoapse import Apoapse
from iuvs import io
d = {}
d['fname']=fname
apo = Apoapse(fname, 300)
iuvsfname = io.ScienceFilename(fname)
min_lat = np.nanmin(apo.lats)
if min_lat < -80:
d['polar'] = True
elif min_lat > -20:
d['equatorial'] = True
return d
In [159]:
from ipyparallel import Client
In [160]:
c = Client()
In [161]:
lbview = c.load_balanced_view()
In [162]:
results = lbview.map_async(process_fname, fnames)
In [ ]:
for res in results:
print(res)
In [164]:
resdf = pd.DataFrame(results.result)
In [165]:
resdf['time'] = resdf.fname.map(lambda x: io.ScienceFilename(x).time)
In [166]:
resdf.set_index('time', inplace=True)
In [167]:
resdf.sort_index(inplace=True)
In [168]:
equatorfname = resdf[resdf.equatorial==True].iloc[0].fname
In [194]:
equatorfname
Out[194]:
In [170]:
polarfname = resdf[resdf.polar==True].iloc[0].fname
In [171]:
polarfname
Out[171]:
In [195]:
equatorapo = Apoapse(equatorfname, 300)
In [196]:
equatorapo.spec.shape
Out[196]:
In [174]:
equatorapo.p_lats[equatorapo.selector]
Out[174]:
In [69]:
np.nanmax(equatorapo.lats)
Out[69]:
In [76]:
%matplotlib nbagg
In [202]:
equatorapo.spec.shape
Out[202]:
In [207]:
pd.DataFrame(equatorapo.spec[12:20,3,:].mean(axis=1))
Out[207]:
In [208]:
for_mike = pd.DataFrame(equatorapo.spec[12:20,3,:].mean(axis=1))
In [209]:
equatorapo.l1b.wavelengths.shape
Out[209]:
In [210]:
for_mike['wavelengths'] = equatorapo.l1b.wavelengths[9]
In [211]:
for_mike
Out[211]:
In [212]:
polarapo = Apoapse(polarfname, 300)
In [213]:
p_lats = polarapo.p_lats[polarapo.selector]
In [214]:
p_lats[p_lats < -80].dropna(how='all', axis=1)
Out[214]:
In [182]:
polarapo.spec.shape
Out[182]:
In [217]:
polarapo.spec[21, 4:8, :].mean(axis=0)
Out[217]:
In [218]:
for_mike['polar'] = polarapo.spec[21, 4:8, :].mean(axis=0)
In [219]:
for_mike.head()
Out[219]:
In [220]:
for_mike.columns = ['equatorial', 'wavelengths', 'polar']
In [221]:
polarfname
Out[221]:
In [222]:
for_mike.set_index('wavelengths').plot(logy=True, title='L_s: 232')
Out[222]:
In [153]:
for_mike.set_index('wavelengths', inplace=True)
In [154]:
for_mike.to_csv('L_s_288_IUVS_spectra.csv')
In [12]:
from astropy.io import fits
In [13]:
hdulist1 = fits.open('/maven_iuvs/production/products/apoapse/day/level1c/fits/mvn_iuv_l1c_apoapse-orbit00264_20141117T115335_v02_r01.fits.gz')
hdulist2 = fits.open('/maven_iuvs/production/products/apoapse/day/level1c/fits/mvn_iuv_l1c_apoapse-orbit00607_20150121T235135_v02_r01.fits.gz')
In [14]:
hdu1 = hdulist1[2]
hdu2 = hdulist2[2]
In [15]:
hdulist2[-1].data['WAVELENGTH_MUV'][0][17]
Out[15]:
In [16]:
import seaborn as sns
sns.set_context('talk')
sns.set_style('white')
In [17]:
%matplotlib nbagg
In [18]:
refl1 = hdu2.data['REFLECTANCE'][0][10]
refl2 = hdu2.data['REFLECTANCE'][0][17]
fig, axes = plt.subplots(nrows=2)
for ax, ref in zip(axes, [refl1, refl2]):
im = ax.imshow(ref.T, origin='lower', vmax=refl1.max(), cmap='viridis', vmin=0,
extent=[-180, 180, -90, 90], aspect='auto')
ax.set_ylim(0,45)
plt.colorbar(im, ax=ax)
In [36]:
ratio = refl1/refl2
In [37]:
plt.figure()
plt.imshow(ratio.T, origin='lower', cmap='viridis')
plt.ylim(0, 45)
plt.colorbar()
Out[37]:
In [23]:
refl1 = hdu1.data['REFLECTANCE'][0][20]
refl2 = hdu2.data['REFLECTANCE'][0][20]
fig, axes = plt.subplots(nrows=2, figsize=(8,6))
for ax, ref, t in zip(axes, [refl1, refl2], ['20141117T115335, Ls 235','20150209T120644, Ls 288']):
im = ax.imshow(ref.T, origin='lower', cmap='viridis', vmax=0.3, vmin=0,
aspect='auto', extent=[-179, 179, -89, 89])
ax.set_ylim(-90,0)
ax.set_title("L1C, " +t)
ax.set_xlabel('Longitude')
ax.set_ylabel('Latitude')
plt.colorbar(im, ax=ax)
fig.tight_layout()
fig.savefig('L1C_comparison.pdf', dpi=150)
In [101]:
hdu.header
Out[101]:
In [102]:
hdulist1[0].header
Out[102]:
In [190]:
hdulist1[5].data['LONGITUDE'][0]
Out[190]:
In [194]:
hdulist1[5].header
Out[194]:
In [ ]: